package com.ccrfid.rmc6.service.business.rollcall2;


import com.ccrfid.rmc6.pojo.dto.rollcall2.RollCallScheduleReload;
import com.google.common.eventbus.EventBus;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class Rollcall2ConfigServiceAspect {
    private static final Logger logger = LoggerFactory.getLogger(Rollcall2ConfigServiceAspect.class);

    @Autowired
    private EventBus eventBus;

    @AfterReturning(value = "execution(* com.ccrfid.rmc6.service.business.rollcall2.Rollcall2ConfigService.createRcSchedule(..))",
            returning = "result")
    public void afterCreateSchedule(Object result) {
        logger.debug("afterCreateSchedule: {}", result);
        eventBus.post(new RollCallScheduleReload());
    }

    @AfterReturning(value = "execution(* com.ccrfid.rmc6.service.business.rollcall2.Rollcall2ConfigService.updateRcSchedule(..))",
            returning = "result")
    public void afterUpdateSchedule(Object result) {
        logger.debug("afterUpdateSchedule: {}", result);
        eventBus.post(new RollCallScheduleReload());
    }

    @AfterReturning(value = "execution(int com.ccrfid.rmc6.service.business.rollcall2.Rollcall2ConfigService.deleteRcScheduleById(..))",
            returning = "result")
    public void afterDeleteSchedules(int result) {
        logger.debug("afterDeleteSchedules: {}", result);
        eventBus.post(new RollCallScheduleReload());
    }
}
